﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PMS.Client.Entities;
using PMS.Client.IBLL;
using PMS.Client.IDAL;
using PMS.Client.Utils;

namespace PMS.Client.BLL
{
    public class OwnerService : ServiceBase, IOwnerService
    {
        IOwnerAccess _ownerAccess;
        public OwnerService(IOwnerAccess ownerAccess)
        {
            _ownerAccess = ownerAccess;
        }

        public BuildingEntity[] GetBuildings()
        {
            string json = _ownerAccess.GetBuildings();
            return this.GetResult<BuildingEntity[]>(json);
        }

        public PageEntity<OwnerEntity[]> GetOwners(ConditionEntity[] keys, int index, int size)
        {
            string json = JsonUtil.Serializer(keys);
            json = _ownerAccess.GetOwners(json, index, size);
            return this.GetResult<PageEntity<OwnerEntity[]>>(json);
        }

        public QuarterEntity[] GetQuarters()
        {
            string json = _ownerAccess.GetQuarters();
            return this.GetResult<QuarterEntity[]>(json);
        }

        public int DeleteOwner(int id)
        {
            string json = _ownerAccess.DeleteOwner(id);
            return this.GetResult<int>(json);
        }

        public int UpdateOwner(OwnerEntity owner)
        {
            string json = JsonUtil.Serializer(owner);
            json = _ownerAccess.UpdateOwner(json);
            return this.GetResult<int>(json);
        }
    }
}
